<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <#include "/comm/module-edit.ftl"/>
</head>
<style type="text/css">

</style>
<body>
<div class="layui-div-body">
    <div class="layui-fluid layui-div-edit">
        <form class="layui-form layui-form-pane" autocomplete="off">
            <div class="layui-form-item">
                <label class="layui-form-label">所属部门</label>
                <div class="layui-input-inline">
                    <div id="goId" initValue="${info.goId!}" lay-filter="goTree"></div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">编辑权限</label>
                <div class="layui-input-block">
                    <input type="checkbox" id="editOpen" name="editOpen" value="1"
                           <#if info.editOpen =='1'>checked</#if>
                           lay-skin="switch" lay-filter="switchTest"
                           title="ON|OFF">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">下载权限</label>
                <div class="layui-input-block">
                    <input type="checkbox" id="editDown" name="editDown" value="1"
                           <#if info.editDown =='1'>checked</#if>
                           lay-skin="switch" lay-filter="switchTest"
                           title="ON|OFF">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" placeholder="请输入姓名" class="layui-input" value="${info.name!}"  lay-verify="required">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号码</label>
                <div class="layui-input-inline">
                    <#if info._id ==''>
                        <input type="text" name="phone" placeholder="请输入手机号码" class="layui-input" value=""  lay-verify="required|phone" maxlength="11">
                    <#else>
                        <input type="text" disabled class="layui-input"
                               value="${info.phone!}">
                    </#if>
                </div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="save">立即提交
                </button>
                <#if info._id ==''>
                    <button type="reset" class="layui-btn layui-btn-primary" id="btn-reset">重置</button>
                </#if>
                <input type="hidden" id="_id" name="_id" value="${info._id}"/>
            </div>
        </form>
    </div>
</div>
<script>
    layui.config({
        base: '${request.contextPath}/assets/lib/' //静态资源所在路径
    }).extend({
        combotree: 'combotree'
    });
    layui.use(['edit', 'combotree'], function () {
        let edit = layui.edit, combotree = layui.combotree, $ = layui.$;
        var form = layui.form;
        edit.render()
        combotree.render({
            id: 'goId',
            elem: '#goId',
            isMultiple: false,
            expandLevel: 2,
            yChkboxType: 's',
            nChkboxType: 's',
            ajaxUrl: "${request.contextPath}/gen/organization/tree",
            placeholder: "请选择所属组织",
            layVerify: 'required'
        });
        // 监听click事件
        combotree.on('click(goTree)', function (obj) {
            // $("#editOpen").val(obj.editOpen);
            $('input[name="editOpen"]').prop('checked', obj.editOpen === 1); // 设置为选中状态或false为未选中状态
            form.render('checkbox'); // 重新渲染以触发事件
            console.log('goId node clicked!', obj);
        });
    });
</script>
</body>

</html>
